package net.zdreamer.geracomium.adapter;

import java.util.List;

import net.zdreamer.geracomium.entity.GridImageInfos.GridImageInfo;
import net.zdreamer.geracomium.ui.home.ReserveAreaActivity;
import net.zdreamer.geracomium.utils.tools_utils.ViewHolder;
import net.zdreamer.geracomium.utils.window.WindowUtil;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.geracomium.R;

public class AreaGridViewAdapter extends MyBaseAdapter<GridImageInfo> {

	private int witch;

	public AreaGridViewAdapter(Context context, List<GridImageInfo> list,
			int res, int witch) {
		super(context, list, res);
		this.witch = witch;
	}

	@Override
	protected View getView(final int position, View convertView,
			ViewGroup parent, GridImageInfo value) {
		char ch = (char) ('A' + position);
		TextView textView = ViewHolder.get(convertView, R.id.text_area_or_room);
		ImageView imageView = ViewHolder.get(convertView, R.id.item_imge);
		LayoutParams layoutParams = imageView.getLayoutParams();
		layoutParams.height = (WindowUtil.getWindowSize(getmContext()).x)*23/66;
		imageView.setLayoutParams(layoutParams);
		textView.setText(String.valueOf(ch) + (witch == 0 ? "区" : "户型"));
		if (witch == 0) {
			ViewHolder.get(convertView, R.id.reserve_touch).setOnClickListener(
					new OnClickListener() {
						@Override
						public void onClick(View v) {
							Intent intent = new Intent(getmContext(),
									ReserveAreaActivity.class);
							intent.putExtra("witch", 1);
							getmContext().startActivity(intent);
						}
					});
		}
		return convertView;
	}
}
